package com.biovr.backend.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * Created by jnmcl on 2017/4/4.
 * 工程初始化
 */
@Component
public class InitRunner implements CommandLineRunner {
    //定义的上传路径
    @Value("${web.upload-path}")
    private String uploadPath;
    //定义的上传临时路径
    @Value("${web.upload-temp-path}")
    private String uploadTempPath;
    //定义的上传二维码路径
    @Value("${web.qcode-path}")
    private String qCodePath;
    @Override
    public void run(String... strings) throws Exception {
        //上传文件夹检查
        File  uploadFolder =new File(uploadPath);
        //临时文件夹
        File uploadTempFolder = new File(uploadTempPath);
        //二维码文件夹
        File qCodeFolder = new File(qCodePath);
        if (!uploadFolder.exists()){
            uploadFolder.mkdir();
        }
        if (!uploadTempFolder.exists()){
            uploadTempFolder.mkdir();
        }
        if (!qCodeFolder.exists()){
            qCodeFolder.mkdir();
        }
    }
}
